def GetLeastNumbers_Solution(tinput, k):
    if tinput is None:
        return None
    if len(tinput) == 0 or len(tinput) < k:
        return None
    array = bubble(tinput, 0, len(tinput))
    return array[0:k]


def bubble(array, lo, hi):
    def swap(array_, index1, index2):
        temp = array_[index1]
        array_[index1] = array_[index2]
        array_[index2] = temp
    for i in range(lo+1, hi):
        for j in range(lo+1, hi-i+1):
            if array[j-1] > array[j]:
                swap(array, j-1, j)
    return array


test_array = [4, 5, 1, 6, 2, 7, 3, 8]
print(GetLeastNumbers_Solution(test_array, 10))
